package com.github.hiling.common.exception;

import lombok.Getter;
import lombok.Setter;

import java.io.Serial;

/**
 * @author hiling
 */
@Setter
@Getter
public class BusinessException extends RuntimeException {
    @Serial
    private static final long serialVersionUID = 5468122937751046392L;

    public BusinessException(Throwable cause) {
        super(cause);
    }

    public BusinessException(String message) {
        super(message);
    }

    public BusinessException(ExceptionMessage message) {
        super(message.getMessage());
        this.code = message.value();
    }

    public BusinessException(Integer code, String message) {
        super(message);
        this.code = code;
    }

    public BusinessException(Integer code, String message, Throwable cause) {
        super(message, cause);
        this.code = code;
    }

    /**
     * 业务定义的异常错误码
     */
    private Integer code;
}